#Trip Expenses #

import TripExpensesTable
import TripExpenseStatusTable

class TripExpenses(TripExpensesTable.TripExpenses, TripExpenseStatusTable.TripExpenseAcceptSatus):
    def __init__(self, MySQLObj):
        self.SQLObj = MySQLObj
        TripExpensesTable.TripExpenses.__init__(self, MySQLObj)
        TripExpenseStatusTable.TripExpenseAcceptSatus.__init__(self, MySQLObj)
        
    def AddExpense(self, EID, PID, Date, Disc, Amount, PeopleInEvent = []):
        TripExpensesTable.TripExpenses.AddExpense(self, EID, PID, Date, Disc, Amount)
        Expense = self.GetExpenses(EID=EID, PID = PID, Date = Date, Disc = Disc)[0] #Amount omitted for rounding issues
        Status = 0
        for PID in PeopleInEvent:
            TripExpenseStatusTable.TripExpenseAcceptSatus.AddPersonExpenseStatus(self, PID, EID, Expense.TexID, 0)
            
    def RemoveExpense(self, Texp_id):
        TripExpensesTable.TripExpenses.RemoveExpense(self, Texp_id)
        TripExpenseStatusTable.TripExpenseAcceptSatus.RemoveExp(self, Texp_id)
        
    def UpdateExpense(self, Expense):
        TripExpensesTable.TripExpenses.UpdateExpense(self, Expense)
        TripExpenseStatusTable.TripExpenseAcceptSatus.UpdateExpense(self, Expense.TexID)



def GenerateTables(MySql):
    import TripExpensesTable
    import TripExpenseStatusTable
    TripExpensesTable.GenerateTables(MySql)
    TripExpenseStatusTable.GenerateTables(MySql)

if __name__ == '__main__':
    P = People(None)



    